<!--
 * @Author: 王灿
 * @Date: 2019-12-02 09:25:05
 * @LastEditTime: 2019-12-02 23:40:09
 * @Description: 退货驳回
 * @FilePath: \scarlet-sparrow-admin\src\views\order\order-refund\refund-reject\index
-->

<template>
  <div class="refund-reject">
    <el-form :model="ruleForm" :rules="rules" ref="ruleForm">
      <el-form-item prop="remark">
          <el-row>
              <el-input v-model="ruleForm.remark" placeholder="请输入驳回原因" clearable></el-input>
          </el-row>
      </el-form-item>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button type="primary" @click="onSubmitForm('ruleForm')">确 定</el-button>
      <el-button @click="onCancelForm('ruleForm')">取 消</el-button>
    </div>
  </div>
</template>
<script>
import { getRefundReject } from '@/api/order.js'
export default {
  name: 'RefundReject',
  props: {
    refundId: {
      type: Number,
      default: 0
    }
  },
  data() {
    return {
      ruleForm: {
        remark: ''
      },
      rules: {
        remark: [{ required: true, message: '请输入', trigger: 'blur' }]
      }
    }
  },
  methods: {
    // 提交
    onSubmitForm(formName) {
      this.$refs[formName].validate(valid => {
        if (valid) {
           // 编辑
            let form = new FormData
            form.append('refundId', this.refundId)
            form.append('remark', this.ruleForm.remark)
            getRefundReject(form).then(res => {
              this.$notify.success({
                title: '提示',
                message: '驳回成功'
              })
              this.onRefresh()
            })
        }
      })
    },
    // 取消
    onCancelForm(formName) {
      this.$refs[formName].resetFields()
      let data = { isShow: false , isRefresh: false}
      this.$emit('onCancelBtn', data)
    },
    // 刷新页面
    onRefresh() {
      setTimeout(() => {
        let data = { isShow: false, isRefresh: true}
        this.$emit('onCancelBtn', data)
      }, 500)
    }
  }
}
</script>

<style lang="scss" scoped>
.customer-vip {
  .el-select {
    width: 100%;
  }
}
</style>